#ifndef _RINGBUFF_H
#define _RINGBUFF_H

#include<stdlib.h>
#include <string.h>

typedef unsigned char* RingBufferDataPointer;
typedef unsigned char  RingBuff_status_t;

#define SUCCESS 	1
#define FAIL 		0

struct RingBuff
{
	RingBufferDataPointer source;	//ringbuff的头部
	RingBufferDataPointer tail;	//尾部
	RingBufferDataPointer write;	//写指针
	RingBufferDataPointer read;	//读指针
	int size;	//ringbuff总长度
	int writed_size;	//写入数据的长度
	int remain_size;	//剩余空间
	
};
typedef struct RingBuff *RingBuff_handle_t;

//初始化RingBuff
RingBuff_handle_t createRingBuff(int size);
//写入RingBuff
RingBuff_status_t writeRingBuff(RingBuff_handle_t handle,RingBufferDataPointer data,int size);
//读取RingBuff
RingBuff_status_t readRingBuff(RingBuff_handle_t handle,RingBufferDataPointer data,int size);
//按字节读取RingBuff
RingBuff_status_t readRingBuffByte(RingBuff_handle_t handle,RingBufferDataPointer data);
//清空RingBuff内存
RingBuff_status_t deleteRingBuff(RingBuff_handle_t handle);
//没啥用
//int getRingBuffWritedSize(RingBuff_handle_t handle);
//int getRingBuffTotalSize(RingBuff_handle_t handle);
//int getRingBuffRemainSize(RingBuff_handle_t handle);


#endif

